/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.classdiagram;

import org.eclipse.gef.commands.CommandStack;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.ui.actions.ActionRegistry;
import org.eclipse.jface.action.IAction;

import com.cea.papyrus.core.editor.DiagramPalette;
import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.editor.abstracteditor.AbstractGraphicalPageWithFlyoutPalette;
import com.cea.papyrus.diagram.classdiagram.action.AddAllFeatures;
import com.cea.papyrus.diagraminterchange2.di2.Diagram;

/**
 * 
 * 
 */
public class ClassDiagramEditor extends AbstractGraphicalPageWithFlyoutPalette 
{
	//Darpan
	public ClassDiagramEditor() {
		
	}

	/**
	 * 
	 */
	private static DiagramPalette PALETTE_MODEL;

	/**
	 * Constructor.
	 * @param modelMngr 
	 * @param diagram 
	 */
	public ClassDiagramEditor( Diagram diagram, ModelManager modelMngr){//, ModelResourceManager resourceManager){
		super( diagram, modelMngr);		
	}

	/**
	 * Constructor.
	 * @param modelMngr 
	 * @param diagram 
	 * @param commandStack 
	 */
	public ClassDiagramEditor( Diagram diagram, ModelManager modelMngr, CommandStack commandStack, ActionRegistry actionRegistry){//, ModelResourceManager resourceManager){
		super( diagram, modelMngr, commandStack, actionRegistry);
	}

	/**
	 * In order to obtain the palette Root.
	 * @return 
	 */
	@Override
	protected PaletteRoot getPaletteRoot() {
		if (PALETTE_MODEL == null) {
			PALETTE_MODEL = ClassDiagramPaletteFactory.createPalette();
		}
		return PALETTE_MODEL;
	}

	/**
	 * 
	 */
	@Override
	protected void configureGraphicalViewer() {
		super.configureGraphicalViewer();

		viewer = getGraphicalViewer();

		// Create and register the EditPartFactory
		viewer.setEditPartFactory(new ClassDiagramGraphicalEditPartsFactory(modelMngr));

		// configure the context menu provider
		cmProvider =
			new ClassDiagramContextMenuProvider(viewer, getActionRegistry(),modelMngr);
		super.configureContextMenuProvider();

	}

	protected void createActions() {
		super.createActions();
		ActionRegistry registry = getActionRegistry();
		IAction action;
		action = new AddAllFeatures(this);
		registry.registerAction(action);
		getSelectionActions().add(action.getId());
	}
}
